<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <button @click="msg = '你好' ">修改msg</button>
        <button @click="msg = '你坏' ">修改msg2</button>
        <button @click="msg = '你好坏' ">修改msg3</button>
        <button @click=" list.push(999) ">添加元素</button>
        <button @click=" list.pop() ">删除元素</button>
        <p> {{ msg }} </p>

        <div v-for="item in list"> {{ item }}</div>
    </div>
    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    msg: 'hello',
                    list: [10,20]
                }
            },
            watch: {
                msg () {
                    // 当msg发生变化，就会调用这个函数
                    console.log('msg改变了')
                },
                list () {
                    // 当list发生变化，就会调用这个函数
                    console.log('list改变了')
                }
            }
        })
    </script>
</body>
</html>